package com.itheima.chapter02.controller;

import com.itheima.chapter02.config.DBConnector;
import com.itheima.chapter02.domain.Consumer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DefaultController {
    @Autowired
    private Environment env;

    @GetMapping("/getPort")
    public String getPort() {
        String port = env.getProperty("server.port");
        System.out.println("server.port = " + port);
        return "server.port = " + port;
    }

    @Autowired
    private Consumer consumer;
    @GetMapping("/getConsumer")
    public Consumer getConsumer() {
        return consumer;
    }
    @Autowired
    private DBConnector dbConnector;
    @GetMapping("/showDB")
    public void showDB() {
        dbConnector.configure();
    }
}
